/**
 * 会员积分model
 */
package com.p2p.front.dal.model;

import java.io.Serializable;
import java.util.Date;

/**
 * @author ruiqi
 *
 */
public class MemberPoint implements Serializable{


	/**
	 * 
	 */
	private static final long serialVersionUID = 348535047086134122L;

	/**
	 * 累计总积分
	 */
	private Integer produceCumulative;
	
	/**
	 * 消耗总消耗
	 */
	private Integer consumeCumulative;
	
	/**
	 * 用户id
	 */
	private String userId;
	
	/**
	 * 积分对应等级
	 */
	private Integer level;
	
	/**
	 * 更新时间
	 */
	private Date updateTime;
	
	/**
	 * 下一等级需要的积分
	 */
	private Integer nextLevelPoint;

	public MemberPoint() {
		// TODO Auto-generated constructor stub
	}
	
	public MemberPoint(String userId) {
		this.userId= userId;
		this.produceCumulative = 0;
		this.consumeCumulative = 0;
		this.level = 0;
	}

	
	public Integer getProduceCumulative() {
		return produceCumulative;
	}

	public void setProduceCumulative(Integer produceCumulative) {
		this.produceCumulative = produceCumulative;
	}

	public Integer getConsumeCumulative() {
		return consumeCumulative;
	}

	public void setConsumeCumulative(Integer consumeCumulative) {
		this.consumeCumulative = consumeCumulative;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	public Integer getCanUsedPoint(){
		return produceCumulative-consumeCumulative;
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}
	
	public Integer getNextLevelPoint() {
		return nextLevelPoint;
	}

	public void setNextLevelPoint(Integer nextLevelPoint) {
		this.nextLevelPoint = nextLevelPoint;
	}

	/**
	 * 增加累计积分
	 * @param point
	 */
	public boolean producePoint(int point){
		this.produceCumulative += point;
		return true;
	}
	
	/**
	 * 消耗累计积分
	 * @param point
	 */
	public boolean consumePoint(int point){
		//积分足够
		if(this.getCanUsedPoint()>=point){
			this.consumeCumulative += point;
			return true;
		}
		return false;
	}
}
